package com.steven.concurrency.example.immutable;

import com.steven.concurrency.annoations.Recommend;
import com.steven.concurrency.annoations.ThreadSafe;
import lombok.extern.slf4j.Slf4j;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

@ThreadSafe
@Recommend
@Slf4j
public class Immutable {

    private static Map<Integer,Integer> map =new HashMap<>();
    static {
        map.put(1,4);
        map.put(2,5);
        map.put(3,6);
        /**
         * 不允许被修改 还可以使用Guava包
         */
        map =Collections.unmodifiableMap(map);
    }

    public static void main(String[] args) {
//        map.put(1,3);
        log.info("{}",map.get(1));
    }
}
